const {addBikeScoreServe} = require('../serve/appletBikeScore.serve')

class AppletBikeScoreController {
    async addBikeScore(ctx) {
        const {bikeId, score} = ctx.request.body;
        const {id: userId} = ctx.state.appletUser;
        console.log(bikeId, score);
        if (bikeId && score) {

            try {
                await addBikeScoreServe({bikeId, score, userId})
                ctx.body = {
                    msg: '评分成功',
                    status: 0,
                }
            } catch (e) {
                console.log(e.message)
                ctx.body = {
                    msg: '评分失败',
                    status: 1,
                }
            }
        } else {
            ctx.body = {
                msg: '缺少必要参数',
                status: 1,
                data: null
            }
        }
    }
}

module.exports = new AppletBikeScoreController();
